<template>
  <div id="app">
    <router-view />
  </div>
</template>

<script>
import { getOssSts } from '@/api/login';
export default {
  name: "app",
  data() {
    return {};
  },
  watch: {},
  created() {
		if (localStorage.getItem('stsToken')) {
      let stsToken = JSON.parse(localStorage.getItem('stsToken'))
			// 如果stsToken存在，则设置过期时间
			localStorage.setItem('stsTokenExpiration', stsToken.expiration)
			// 如果过期时间小于当前时间，则重新获取stsToken
			if (this.$moment(stsToken.expiration).valueOf() < this.$moment().valueOf()) {
				this.getSts()
			}
		} else {
			this.getSts()
		}

  },
  mounted() {
    this.$initWebSocket();
  },
  methods: {
    getSts() {
			  getOssSts().then(res => {
        // 存到本地
        localStorage.setItem('stsToken', JSON.stringify(res))
			})
		},
  },
  computed: {},
};
</script>
<style>
body,
p {
  margin: 0;
  padding: 0
}
.w-100 {
  width: 100%;
}
.el-dialog__header{
  border-bottom: 1px solid #eee;
}
.el-dialog__footer{
  border-top: 1px solid #eee;
}
</style>
